Release 10.1A: OpenEdge Data Management:
SQL Reference


PREFIX

Returns the substring of a character string, starting from the position specified by start_pos and ending before the specified character.

Syntax

PREFIX ( char_expression , start_pos , char_expression ) 

char_expression

Evaluates to a character string, typically a character-string literal or column name. If the expression evaluates to NULL, PREFIX returns NULL.

start_pos

Evaluates to an integer value. PREFIX searches the string specified in the first argument starting at that position. A value of 1 indicates the first character of the string.

char_expression

Evaluates to a single character. PREFIX returns the substring that ends before that character. If PREFIX does not find the character, it returns the substring beginning at start_pos, to the end of the string. If the expression evaluates to more than one character, PREFIX ignores all but the first character.

Example

The following example shows one way to use the PREFIX function:

create table prefix_table  
     ( 
     colstring varchar(20), 
     colchar char(1) 
     ); 
  
insert into prefix_table values ('string.with.dots', '.'); 
  
insert into prefix_table values ('string-with-dashes', '-'); 
  
select colstring, colchar, prefix(colstring, 1, '.') from prefix_table; 
COLSTRING             COLCHAR               prefix(COLSTRING,1,.)   
--------------------- --------------------- ----------------------  
string.with.dots      .                     string                  
string-with-dashes    -                     string-with-dashes      
  
  
select colstring, colchar, prefix(colstring, 1, colchar) from prefix_table; 
  
COLSTRING             COLCHAR               prefix(COLSTRING,1,COLCHAR)   
--------------------- --------------------- ----------------------------  
string.with.dots      .                     string                        
string-with-dashes    -                     string                        
  
  
select colstring, colchar, prefix(colstring, 1, 'X') from prefix_table; 
  
COLSTRING             COLCHAR               prefix(COLSTRING,1,X)   
--------------------- --------------------- ----------------------  
string.with.dots      .                     string.with.dots        
string-with-dashes    -                     string-with-dashes  

Note

Compatibility

Progress extension


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095